<template>
  <div>
    <!-- 弹窗 -->
    <el-dialog :title="`${title}详细信息`" :visible.sync="dialogVisible" width="700px">
      <el-card class="box-card">
        <el-descriptions>
          <el-descriptions-item label="头像">
            <image-preview width="120px" height="120px" :src="detailsData.avatar" />
          </el-descriptions-item>
          <el-descriptions-item label="姓名">{{ this.title }}</el-descriptions-item>
          <el-descriptions-item label="性别">
            <el-tag v-if="detailsData.sex == 0">男</el-tag>
            <el-tag type="danger" v-if="detailsData.sex == 1">女</el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="年龄">{{ detailsData.age }}</el-descriptions-item>
          <el-descriptions-item label="手机号">{{ detailsData.phone }}</el-descriptions-item>
          <el-descriptions-item label="备注" v-if="state"> {{ detailsData.remark }} </el-descriptions-item>
          <el-descriptions-item label="简介" v-if="!state"> {{ detailsData.description }} </el-descriptions-item>
        </el-descriptions>
      </el-card>

      <span slot="footer" class="dialog-footer">
        <el-button @click="resetForm">返 回</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import defAva from '@/assets/images/profile.jpg'
export default {
  data() {
    return {
      dialogVisible: false,
      detailsData: {},
      title: '',
      state: false,
    }
  },
  methods: {
    // 表单重置
    resetForm() {
      this.dialogVisible = false
      this.detailsData = {}
    },
    // 获取数据
    getList(name) {
      const combinedArray = [
        // 医生数据
        {
          "age": 35,
          "createTime": "2023-05-12 14:30:45",
          "name": "张伟",
          "sex": '0',
          "phone": "13800138001",
          "description": "心血管内科专家，10年临床经验，擅长高血压、冠心病诊治。",
          "avatar": defAva,
        },
        {
          "age": 42,
          "createTime": "2023-07-23 09:15:22",
          "name": "李娜",
          "sex": '1',
          "phone": "13900139002",
          "description": "妇产科主任医师，精通高危妊娠管理和妇科微创手术。",
          "avatar": defAva,
        },
        {
          "age": 28,
          "createTime": "2023-02-18 16:45:10",
          "name": "王芳",
          "sex": '1',
          "phone": "13700137003",
          "description": "儿科医师，擅长儿童呼吸系统疾病和新生儿护理。",
          "avatar": defAva,
        },
        {
          "age": 50,
          "createTime": "2023-11-05 08:20:35",
          "name": "赵建国",
          "sex": '0',
          "phone": "13600136004",
          "description": "骨科教授，专注关节置换和运动损伤修复20余年。",
          "avatar": defAva,
        },
        {
          "age": 38,
          "createTime": "2023-09-30 13:10:28",
          "name": "陈静",
          "sex": '1',
          "phone": "13500135005",
          "description": "神经内科副主任医师，擅长脑血管疾病和帕金森病治疗。",
          "avatar": defAva,
        },
        {
          "age": 45,
          "createTime": "2023-04-17 10:55:42",
          "name": "刘强",
          "sex": '0',
          "phone": "13400134006",
          "description": "普外科专家，精通腹腔镜手术和胃肠道肿瘤治疗。",
          "avatar": defAva,
        },
        {
          "age": 31,
          "createTime": "2023-08-22 15:25:19",
          "name": "孙丽",
          "sex": '1',
          "phone": "13300133007",
          "description": "眼科医师，专长白内障手术和青少年近视防控。",
          "avatar": defAva,
        },
        {
          "age": 56,
          "createTime": "2023-01-08 11:40:33",
          "name": "周明",
          "sex": '0',
          "phone": "13200132008",
          "description": "中医科主任，擅长针灸治疗慢性疼痛和亚健康调理。",
          "avatar": defAva,
        },
        {
          "age": 33,
          "createTime": "2023-06-14 17:05:57",
          "name": "吴婷",
          "sex": '1',
          "phone": "13100131009",
          "description": "皮肤科主治医师，专注痤疮、湿疹等常见皮肤病治疗。",
          "avatar": defAva,
        },
        {
          "age": 48,
          "createTime": "2023-10-29 07:50:14",
          "name": "郑强",
          "sex": '0',
          "phone": "13000130010",
          "description": "肿瘤科副主任，擅长肺癌和乳腺癌的个体化综合治疗。",
          "avatar": defAva,
        },

        // 患者数据
        {
          "name": "王小明",
          "createTime": "2024-03-15 09:23:45",
          "sex": "0",
          "age": 35,
          "phone": "13812345678",
          "avatar": defAva,
          "remark": "高血压患者，需定期复查"
        },
        {
          "name": "李丽",
          "createTime": "2024-02-28 14:12:33",
          "sex": "1",
          "age": 28,
          "phone": "13987654321",
          "avatar": defAva,
          "remark": "糖尿病患者，胰岛素依赖型"
        },
        {
          "name": "张建国",
          "createTime": "2024-01-10 16:45:22",
          "sex": "0",
          "age": 52,
          "phone": "13711223344",
          "avatar": defAva,
          "remark": "术后恢复期，需定期换药"
        },
        {
          "name": "刘芳",
          "createTime": "2024-03-05 11:30:15",
          "sex": "1",
          "age": 30,
          "phone": "13655667788",
          "avatar": defAva,
          "remark": "孕妇，定期产检"
        },
        {
          "name": "陈伟",
          "createTime": "2024-02-18 08:50:42",
          "sex": "0",
          "age": 45,
          "phone": "13599887766",
          "avatar": defAva,
          "remark": "哮喘患者，随身携带药物"
        },
        {
          "name": "赵静",
          "createTime": "2024-01-25 13:20:19",
          "sex": "1",
          "age": 22,
          "phone": "13411223344",
          "avatar": defAva,
          "remark": "过敏体质，青霉素过敏"
        },
        {
          "name": "孙强",
          "createTime": "2024-03-10 10:15:37",
          "sex": "0",
          "age": 60,
          "phone": "13344556677",
          "avatar": defAva,
          "remark": "体检发现肺部结节，需随访"
        },
        {
          "name": "周梅",
          "createTime": "2024-02-05 15:40:28",
          "sex": "1",
          "age": 38,
          "phone": "13277889900",
          "avatar": defAva,
          "remark": "抑郁症患者，定期心理咨询"
        },
        {
          "name": "吴勇",
          "createTime": "2024-01-15 17:25:53",
          "sex": "0",
          "age": 41,
          "phone": "13122334455",
          "avatar": defAva,
          "remark": "腰椎间盘突出，康复治疗中"
        },
        {
          "name": "郑雪",
          "createTime": "2024-03-20 07:30:10",
          "sex": "1",
          "age": 27,
          "phone": "13066778899",
          "avatar": defAva,
          "remark": "甲状腺功能减退，长期服药"
        }
      ];
      this.detailsData = combinedArray.find(item => item.name === name);
      return this.detailsData
    }
  },

}
</script>

<style lang="scss" scoped></style>